﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace DocGenerator
{
    public class Article
    {
        public int No { get; set; }
        public string Name { get; set; }
        public const string MeasurementUnit = "бр.";
        public decimal Quantity { get; set; }
        public decimal Price { get; set; }
        public decimal Amount { get; set; }
        public decimal DDV { get; set; }
        public decimal AmountDDV { get; set; }
        public decimal Total { get; set; }

        public void ArticleCalculaitons()
        {
            this.Amount = Math.Round(this.Quantity * this.Price, MidpointRounding.AwayFromZero);
            this.DDV = decimal.Parse(ConfigurationManager.AppSettings["DDV"].ToString(), System.Globalization.CultureInfo.InvariantCulture);
            this.AmountDDV = Math.Round(this.Amount * this.DDV / 100, 2);
            this.Total = this.Amount + Math.Round(this.Amount * this.DDV / 100, 2, MidpointRounding.AwayFromZero);
        }
    }
}
